<% layout('/layouts/default.html', {title: '商品列表', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa fa-list-alt"></i> ${brandName} -- ${text('商品列表')}
			</div>
			<div class="box-tools pull-right">
				<a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i> ${text('查询')}</a>
				
				
				
			</div>
		</div>
		<div class="box-body">
			<#form:form id="searchForm" model="${ztGoods}" action="${ctx}/ztGoods/brandListData" method="post" class="form-inline hide"
					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
												
				
			
				
				<div class="form-group">
					<label class="control-label">${text('商品名')}：</label>
					<div class="control-inline width-400">
						<#form:input path="title" maxlength="400" class="form-control width-400"/>
					</div>
				</div>
				
				
				
				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
					<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
				</div>
			</#form:form>
			<table id="dataGrid"></table>
			<div id="dataGridPage"></div>
		</div>
	</div>
</div>
<% } %>
<script>


// 初始化DataGrid对象
$('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	columnModel: [ 
		{header:'${text('栏目类型')}', name:'goodstemp', index:'a.goodstemp', width:130, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('zt_goodstemp_type')}, val, '${text('未知')}', true);
		}},
		{header:'${text('商品类型')}', name:'typeName', width:100, align:"center"},
		{header:'${text('品牌')}', name:'brandName', width:100, align:"center"},
		{header:'${text('商品编号')}', name:'code', index:'a.code', width:110, align:"center"},
		
		{header:'${text('商品名')}', name:'title', index:'a.name', width:230, align:"center"},
		
		{header:'${text('商品原价')}', name:'origPrice', index:'a.orig_price', width:120, align:"center"},
		
		{header:'${text('图片')}', name:'img',  width:95, align:"center",formatter: function(val, obj, row, act){
			return '<img style="width:40px;height:40px;" src="'+val+'"></img>';
		}},
		
		{header:'${text('库存数量')}', name:'count', index:'a.count', width:98, align:"center"},
		{header:'${text('已售数量')}', name:'soldCount', index:'a.sold_count', width:115, align:"center"},
		
		{header:'${text('上架状态')}', name:'sjStatus', index:'a.sj_status', width:100, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('zt_sj_type')}, val, '${text('未上架')}', true);
		}},
	
		{header:'${text('更新时间')}', name:'createDate', index:'a.create_date', width:160, align:"center"},
		
		{header:'${text('操作')}', name:'actions', width:115, sortable:false, title:false, formatter: function(val, obj, row, act){
			var actions = [];
			<% if(hasPermi('ztGoods:ztGoodsData:edit')){ %>
				
				
				
				actions.push('<a href="${ctx}/ztGoods/delete?id='+row.id+'" class="btnList" title="${text('删除商品')}" data-confirm="${text('确认要删除该商品吗？')}"><i class="fa fa-trash-o"></i></a>&nbsp;');
				
				actions.push('<a href="${ctx}/ztGoods/ishidden?id='+row.id+'" class="btnList" title="${text('商品不显示在专场')}" data-confirm="${text('确认要将该商品不显示在该品牌专场吗？')}"><i class="fa fa-stethoscope"></i></a>&nbsp;');
				
				if (row.sjStatus == '0'){
					actions.push('<a href="${ctx}/ztGoods/enable?id='+row.id+'" class="btnList" title="${text('商品上架')}" data-confirm="${text('确认要上架该商品吗？')}"><i class="glyphicon glyphicon-ok-circle"></i></a>&nbsp;');
				}
				if (row.sjStatus == '1'){
					actions.push('<a href="${ctx}/ztGoods/disable?id='+row.id+'"class="btnList" title="${text('商品下架')}" data-confirm="${text('确认要下架该商品吗？')}"><i class="glyphicon glyphicon-ban-circle"></i></a>&nbsp;');
				}
				
				if (row.sjStatus == '2'){
					actions.push('<a href="${ctx}/ztGoods/enable?id='+row.id+'" class="btnList" title="${text('商品上架')}" data-confirm="${text('确认要上架该商品吗？')}"><i class="glyphicon glyphicon-ok-circle"></i></a>&nbsp;');
				}
				
			<% } %>
			return actions.join('');
		}},
		{header:'${text('商品推荐')}', name:'actions', width:100,align:"center", sortable:false, title:false, formatter: function(val, obj, row, act){	
			return '<a href="${ctx}/ztComment/list?ztGoods.id='+row.id+'" class="btnList" title="${text('商品推荐')}">商品推荐</a>';
		}}
		
	],
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});
</script>